import Vue from 'vue'

import Cookies from 'js-cookie'

// import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'
import '@/assets/iconfont/iconfont.css'
import '@/assets/font/iconfont.css'


import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import i18n from './lang' // internationalization
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters

// import VueDND from 'awe-dnd'
const defaultSettings = require('@/settings.js')
// Vue.use(VueDND)

import 'hhframe-web/hhframe-web/hhframe.css'

import '../public/hhEditor.1.0.0/ueditor.config.js'
import "../public/hhEditor.1.0.0/ueditor.all.min.js"
import "../public/hhEditor.1.0.0/lang/zh-cn/zh-cn.js"
// excel导出
import JsonExcel from "vue-json-excel";
Vue.component("downloadExcel", JsonExcel);
Vue.prototype.Format = function (timeStamp) {
  let year = timeStamp.getFullYear();
  let month = timeStamp.getMonth() + 1 < 10 ? "0" + (timeStamp.getMonth() + 1) : timeStamp.getMonth() + 1;
  let date = timeStamp.getDate() < 10 ? "0" + timeStamp.getDate() : timeStamp.getDate();
  let hh = timeStamp.getHours() < 10 ? "0" + timeStamp.getHours() : timeStamp.getHours();
  let mm = timeStamp.getMinutes() < 10 ? "0" + timeStamp.getMinutes() : timeStamp.getMinutes();
  let ss = timeStamp.getSeconds() < 10 ? "0" + timeStamp.getSeconds() : timeStamp.getSeconds();
  let nowTime = year + "年" + month + "月" + date + "日" + " " + hh + ":" + mm + ':' + ss;
  return nowTime
};

// 图片预览
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
Vue.use(Viewer)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value),
	zIndex:1000
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.prototype.$eventHub = new Vue()
Vue.config.productionTip = false

// 收货地址处理
Vue.prototype.$setAddr = function(data,type) {
	if(!data||!type) return;
	let addr = data;
	if(type!=1){
		addr = data.split('-')[3];
	}
	return addr;
};

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
